package cn.edu.jxau.test;

/**
 * 递归实现斐波那契数列
 * 
 * @author Fudashi
 */
public class Main {

	public static void main(String[] args) {
		//0 1 1 2 3 5 8 13 21
		System.out.println(fibonacci(5));
		System.out.println(fibonacci(6));
		System.out.println(fibonacci(7));
		System.out.println(fibonacci(8));
	}

	private static long fibonacci(long i) {
		if (i == 0) {
			return 0;
		} else if (i == 1 || i == 2) {
			return 1;
		} else {
			return fibonacci(i - 1) + fibonacci(i - 2);
		}
	}
}
